package com.huirui.server.controller.mini.program;

import com.huirui.server.pojo.dto.UserSettingDto;
import com.huirui.server.pojo.result.Result;
import com.huirui.server.pojo.vo.UserSettingVo;
import com.huirui.server.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/setting")
@Slf4j
@Validated
@Tag(name = "设置管理", description = "微信小程序用户设置相关相关")
public class SettingController {

    @Resource
    private UserService userService;

    @GetMapping
    @Operation(summary = "获取用户设置信息")
    public Result<UserSettingVo> getUserSettingInfo() {
        UserSettingVo userSettingVo = userService.getUserSettingInfo();
        return Result.success(userSettingVo);
    }

    @PatchMapping
    @Operation(summary = "修改用户的个人信息")
    public Result<Void> updateUserInformation(@Validated @RequestBody UserSettingDto userSettingDto) {
        userService.updateUserInformation(userSettingDto);
        return Result.success();
    }
}
